namespace Doc.CodeSamples.Tests
{
    #region example
    using UnityEngine;
    using Unity.Entities;

    [ExecuteInEditMode]
    class SpawnerAuthoring : MonoBehaviour
    {
        public GameObject Prefab;
        public int count;
        public int id;
        public bool updateId;

        private void OnEnable()
        {
            name = Prefab.name;
            if (updateId)
                id = Prefab.GetInstanceID();
        }
    }

    class SpawnerBaker : Baker<SpawnerAuthoring>
    {
        public override void Bake(SpawnerAuthoring authoring)
        {
            var entity = GetEntity(TransformUsageFlags.None);
            AddComponent(entity, new Spawner
            {
                // By default, each authoring GameObject turns into an Entity.
                // Given a GameObject (or authoring component), GetEntity looks up the resulting Entity.
                Prefab = GetEntity(authoring.Prefab, TransformUsageFlags.Dynamic),
                position = authoring.Prefab.transform.position,
                forward = authoring.Prefab.transform.forward,
                up = authoring.Prefab.transform.up,
                scale = authoring.Prefab.transform.localScale,
                count = authoring.count,
                id = authoring.id
            });
        }
    }
    #endregion
}
